const connection = require("../app/database");
class userSerice {
  async create(user) {
    const { name, password, email, age, gender } = user;
    const stamemt = `INSERT INTO user (name, password, email, age, gender) VALUES (?, ?, ?, ?, ?);`;
    const result = await connection.execute(stamemt, [
      name,
      password,
      email,
      age,
      gender,
    ]);
    return result;
  }
  async getUserByName(name) {
    const statement = `SELECT * FROM  user  WHERE name = ?`;
    const [result] = await connection.execute(statement, [name]);
    return result[0];
  }
  async getEmail(email) {
    const statement = `SELECT * FROM  user  WHERE email = ?`;
    const [result] = await connection.execute(statement, [email]);
    return result[0];
  }
}

module.exports = new userSerice();
